package com.digitalchina.lxnsy.viewholder;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.activity.old.TechnologyTrainingVideoSignUpActivity;
import com.digitalchina.lxnsy.entity.TrainingListVO;
import com.digitalchina.lxnsy.toolkit.DateStyle;
import com.digitalchina.lxnsy.toolkit.DateUtil;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2017/3/24 10:33
 * 修改备注：2018年1月31日 14:57:20 新增直播字段
 * ================================================
 */

public class TechnologyTrainingVideoListV2Holder extends BaseViewHolder<TrainingListVO> {

    private TextView technologyTrainingVideoListTvTitle;
    private TextView technologyTrainingVideoListTvTrainingTeacher;
    private TextView technologyTrainingVideoListTvPageView;
    private SimpleDraweeView technologyTrainingVideoListSdvVideo;

    private TextView tvLiveStatus; // 直播状态
    private TextView tvLiveTime; // 直播开始时间
    private TextView tvSignUp; // 报名


    public TechnologyTrainingVideoListV2Holder(ViewGroup parent) {
        super(parent, R.layout.item_technology_training_video_list_v2);

        technologyTrainingVideoListSdvVideo = $(R.id.technology_training_video_list_sdv_video);
        technologyTrainingVideoListTvTitle = $(R.id.technology_training_video_list_tv_title);
        technologyTrainingVideoListTvTrainingTeacher = $(R.id.technology_training_video_list_tv_training_teacher);
        technologyTrainingVideoListTvPageView = $(R.id.technology_training_video_list_tv_pageView);
        tvSignUp = $(R.id.tv_sign_up);

        tvLiveStatus = $(R.id.tv_live_status);
        tvLiveTime = $(R.id.tv_live_time);


    }

    @Override
    public void setData(final TrainingListVO data) {
        super.setData(data);
        if (data == null)
            return;

        FrescoUtil.showImageSmall(data.getImg(), technologyTrainingVideoListSdvVideo);
        technologyTrainingVideoListTvPageView.setText(data.getViewCount() + "次播放");

        // 如果是直播  code=1516
        if (data.getVideoType().getCode().equals("1516")) {
            //technologyTrainingVideoListTvPageView.setVisibility(View.GONE);
            tvLiveStatus.setVisibility(View.VISIBLE);

            //直播状态 //0 未开始 1 直播中 -1结束
     /*       switch (data.getLiveState()) {
                case 0:
                    tvLiveStatus.setText("●预告");
                    tvLiveStatus.setBackgroundResource(R.color.video_color_advance);
                    tvLiveTime.setVisibility(View.VISIBLE);
                    tvSignUp.setVisibility(View.VISIBLE);
                    tvLiveTime.setText(DateUtil.getDate(data.getLiveDate() + " " + data.getStartTime(), DateStyle.MM_DD_HH_MM));
                    break;
                case 1:
                    tvLiveStatus.setText("●直播中");
                    tvLiveStatus.setBackgroundResource(R.color.video_color_live);
                    tvLiveTime.setVisibility(View.GONE);
                    tvSignUp.setVisibility(View.GONE);
                    break;
                case -1:
                    tvLiveStatus.setText("●回放");
                    tvLiveStatus.setBackgroundResource(R.color.video_color_playback);
                    tvLiveTime.setVisibility(View.GONE);
                    tvSignUp.setVisibility(View.GONE);
                    break;
            }*/

            tvLiveStatus.setText("●回放");
            tvLiveStatus.setBackgroundResource(R.color.video_color_playback);
            tvLiveTime.setVisibility(View.GONE);
            tvSignUp.setVisibility(View.GONE);

            // 直播展示标题
            technologyTrainingVideoListTvTrainingTeacher.setText(data.getName());
            // 之前的标题展示专家
            technologyTrainingVideoListTvTitle.setText("直播专家：" + data.getTeacherName());

            tvSignUp.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    GotoUtil.gotoActivity((Activity) getContext(), TechnologyTrainingVideoSignUpActivity.class, "agriClassesId", data.getId());
                }
            });
        } else {
            //technologyTrainingVideoListTvPageView.setVisibility(View.VISIBLE);
            tvLiveStatus.setVisibility(View.GONE);
            tvLiveTime.setVisibility(View.GONE);
            tvSignUp.setVisibility(View.GONE);

            // 非直播展示专家姓名
            technologyTrainingVideoListTvTrainingTeacher.setText(data.getTeacherName());
            technologyTrainingVideoListTvTitle.setText(data.getName());
        }


    }
}
